﻿using Microsoft.EntityFrameworkCore.Migrations;

namespace Magicodes.Admin.Migrations
{
    public partial class _2 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_SFOrders_WULINGAddressses_AddresId",
                table: "SFOrders");

            migrationBuilder.DropIndex(
                name: "IX_SFOrders_AddresId",
                table: "SFOrders");

            migrationBuilder.DropPrimaryKey(
                name: "PK_WULINGAddressses",
                table: "WULINGAddressses");

            migrationBuilder.DropColumn(
                name: "AddresId",
                table: "SFOrders");

            migrationBuilder.RenameTable(
                name: "WULINGAddressses",
                newName: "WULINGAddresss");

            migrationBuilder.AlterColumn<string>(
                name: "ServiceStationCode",
                table: "SFOrders",
                nullable: false,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AddColumn<string>(
                name: "AddressCoalescing",
                table: "SFOrders",
                nullable: true);

            migrationBuilder.AddColumn<bool>(
                name: "IsWithSFQiaoCreateOrder",
                table: "SFOrders",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AlterColumn<string>(
                name: "ServiceStationName",
                table: "WULINGAddresss",
                nullable: false,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "ServiceStationCode",
                table: "WULINGAddresss",
                nullable: false,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "ReceiverAddress",
                table: "WULINGAddresss",
                nullable: false,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "ContactPhoneNumber",
                table: "WULINGAddresss",
                nullable: false,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "Contact",
                table: "WULINGAddresss",
                nullable: false,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AddPrimaryKey(
                name: "PK_WULINGAddresss",
                table: "WULINGAddresss",
                column: "Id");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropPrimaryKey(
                name: "PK_WULINGAddresss",
                table: "WULINGAddresss");

            migrationBuilder.DropColumn(
                name: "AddressCoalescing",
                table: "SFOrders");

            migrationBuilder.DropColumn(
                name: "IsWithSFQiaoCreateOrder",
                table: "SFOrders");

            migrationBuilder.RenameTable(
                name: "WULINGAddresss",
                newName: "WULINGAddressses");

            migrationBuilder.AlterColumn<string>(
                name: "ServiceStationCode",
                table: "SFOrders",
                nullable: true,
                oldClrType: typeof(string));

            migrationBuilder.AddColumn<long>(
                name: "AddresId",
                table: "SFOrders",
                nullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "ServiceStationName",
                table: "WULINGAddressses",
                nullable: true,
                oldClrType: typeof(string));

            migrationBuilder.AlterColumn<string>(
                name: "ServiceStationCode",
                table: "WULINGAddressses",
                nullable: true,
                oldClrType: typeof(string));

            migrationBuilder.AlterColumn<string>(
                name: "ReceiverAddress",
                table: "WULINGAddressses",
                nullable: true,
                oldClrType: typeof(string));

            migrationBuilder.AlterColumn<string>(
                name: "ContactPhoneNumber",
                table: "WULINGAddressses",
                nullable: true,
                oldClrType: typeof(string));

            migrationBuilder.AlterColumn<string>(
                name: "Contact",
                table: "WULINGAddressses",
                nullable: true,
                oldClrType: typeof(string));

            migrationBuilder.AddPrimaryKey(
                name: "PK_WULINGAddressses",
                table: "WULINGAddressses",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_SFOrders_AddresId",
                table: "SFOrders",
                column: "AddresId");

            migrationBuilder.AddForeignKey(
                name: "FK_SFOrders_WULINGAddressses_AddresId",
                table: "SFOrders",
                column: "AddresId",
                principalTable: "WULINGAddressses",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }
    }
}
